<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1">
    <meta content=always name=referrer>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/swiper.min.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/base_user.css">
    <script src="__STATIC__/js/jquery-1.8.2.js"></script>
    <script src="__STATIC__/js/swiper.min.js"></script>
    <title>商品详情</title>
    <script src="__STATIC__/js/layer_mobile/layer.js"></script>
    <style>
        .tw img {
            width: 100% !important;
            padding-left: 0 !important;
        }

        th, td {
            font-size: 12px;
            text-align: center;
            padding: 1% 0;
        }

        .and {
            width: 4% !important;
        }

        .center table {
            width: 94%;
            margin: 0px auto;
        }

        .center table td {
            width: 33.3%;
            font-size: 12px;
            color: #848484;
        }

        .address_det ul {
            padding-bottom: 10px;
        }

        .address_det ul li {
            padding: 0 3% 0 8%;
            font-size: 13px;
            line-height: 24px;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
        }

        .address_det ul li a {
            color: #333;
            display: block;
        }

        .address_det ul li.active a {
            color: #E73F09;
        }

        .address_det ul li:first-child {
            background: url("__STATIC__/img-new/new_icon4.png") no-repeat center left;
            background-size: 18px 18px;
        }
        .tw p{
            font-size: 12px;
            line-height: 18px;
            padding-top: 5px;
        }

    </style>
    <script>
        $(function () {
            $('.tw').find('img').parent('p').css('font-size', 0);  //防空白
            //数量初始化
            $('#num').val('1');
            $(".tablist li").click(
                    function () {
                        var a = $(".tablist li").index(this);
                        $(this).addClass("cur");
                        $(this).siblings().removeClass("cur");
                        $(".tabcon>div").eq(a).css({display: "block"});
                        $(".tabcon>div").eq(a).siblings().css({display: "none"});
                    }
            );
            $(".size li").click(
                    function () {
                        $(this).addClass("cur");
                        $(this).addClass("selected_attr");
                        $(this).siblings().removeClass("cur");
                        $(this).siblings().removeClass("selected_attr");
                        text_change();
                    }
            );
            function text_change() {
                //改变值
                var text = '';
                $('.selected_attr').each(function (i, o) {
                    text += $(o).text() + ',';
                });
                var new_text = text.substr(0, text.length - 1);
                $('#text_selected').text(new_text);

                if (!"{$limit_status}") {
                    if (!"{$special_status}" && !"{$special_price}") {
                        //非限时商品和特价商品
                        ajax_new(new_text);
                    }
                }
            }

            //ajax调用新价格
            function ajax_new(text) {
                var goods_id = $('#goods_id').val();
                $.post('new_attr', {'text': text, 'goods_id': goods_id}, function (t) {
                    if (t.id == 0) {
                        layer.open({content: t.message, skin: 'msg', time: 2});
                    } else {
                        $('#selected_price').text(t.price);
                        $('#goods_attr_id').val(t.id);
                        $('#inventory').val(t.inventory);
                    }
                })
            }

            $(function () {
                text_change();
                $(window).scroll(function () {
                    if ($(window).scrollTop() >= 50) {
                        $('.top').fadeIn(300);
                    } else {
                        $('.top').fadeOut(300);
                    }
                });
                $('.top').click(function () {
                    $('html,body').animate({scrollTop: '0px'}, 800);
                });
                $(".footer .list2 li").click(
                        function () {
                            var h = $(document.body).height();
                            $(".board").height(h + "px");
                            $(".spsx").css({display: "block"});
                        }
                );
                $(".spsx .cancel").click(
                        function () {
                            $(".board").height("");
                            $(".spsx").css({display: ""});
                        }
                )
                $(".next_address").click(
                        function () {
                            var h = $(document.body).height();
                            $(".board").height(h + "px");
                            $(".address_det").css({display: "block"});
                        }
                );
                $(".address_det .cancel").click(
                        function () {
                            $(".board").height("");
                            $(".address_det").hide();
                        }
                )
            });
        });
        //选择属性分类
        function selectAttr() {
            var h = $(document.body).height();
            $(".board").height(h + "px");
            $(".spsx").css({display: "block"});
        }

    </script>
    <script>
        $(function () {
            $(".header_col li,.address_det ul li").click(
                    function () {
                        $(this).addClass("active").siblings().removeClass("active");
                    }
            )
            $(".img").click(
                    function () {
                        $(".menu").toggle();
                    }
            )
//            详情
            $('#i_goods').click(function () {
                $('html,body').animate({scrollTop: $('#i_goods_con').offset().top}, 100);
            });
            $('#i_det').click(function () {
                $('html,body').animate({scrollTop: $('#i_det_con').offset().top}, 500);
            });
            $('#i_review').click(function () {
                $('html,body').animate({scrollTop: $('#i_rew_con').offset().top}, 500);
            });
        })
    </script>
    <style>
        header {
            width: 100%;
            height: 50px;
            position: relative;
            text-align: center;
            background: white;
        }

        header .back {
            position: absolute;
            top: 50%;
            margin-top: -9px;
            width: 10px;
            /*height: 19px;*/
            left: 3%;
            /*transform: scale(0.7);*/
        }

        header .small {
            font-size: 12px;
            position: absolute;
            right: 3%;
            line-height: 30px;
            top: 50%;
            margin-top: -15px;
            color: white;
        }

        .header_col {
            overflow: hidden;
            margin: 0px auto;
            display: inline-block;
        }

        .header_col li {
            padding: 0 10px;
            float: left;
            color: #333;
            font-size: 14px;
            line-height: 50px;
            position: relative;
        }

        .header_col li a {
            display: block;
            color: #333;
        }

        .header_col .active::after {
            position: absolute;
            content: '';
            bottom: 0;
            width: 40px;
            height: 1px;
            background: #333;
            left: 50%;
            margin-left: -20px;
        }

        .header_col .active a {
            color: #333;
        }
    </style>

</head>
<body>
<div class="wrap-det">
    <header>
        <img src="__STATIC__/img_user/back.png" class="back" onclick="back_url()">
        <ul class="header_col">
            <li class="active" id="i_goods"><a href="#">商品</a></li>
            <li id="i_det"><a href="#">详情</a></li>
            <li id="i_review"><a href="#">评价</a></li>
        </ul>
        <img src="__STATIC__/img/cart.png" style="width:20px;position: absolute;right:15%;top:50%;margin-top: -8px;"
             onclick="to_cart()">
        <div style="position: absolute;right:3%;top:10px;">
            <img src="__STATIC__/img_user/sp-qita.png" class="img"
                 style="transform:rotate(90deg);width: 28px;height: 28px;">
            <!--右侧...开始-->
            <div class="menu" id="menu">
                <table border="0">
                    <tr>
                        <td><img src="__STATIC__/img/sp-shouye.png"></td>
                        <td><a href="{:url('mobile/user_port/index')}">首页</a></td>
                    </tr>

                    <tr><a>
                        <td><img src="__STATIC__/img_user/sp-fenxiang.png" onclick="share()"></td>
                        <td onclick="share()">分享</td>
                    </a>
                    </tr>
                </table>
            </div>
            <!--右侧...结束-->
        </div>
    </header>
    <input type="hidden" id="goods_id" value="{:input('goods_id')}"/>
    <input type="hidden" id="inventory"/>
    <!--banner开始-->
    <div class="swiper-container head" id="i_goods_con">
        <div class="swiper-wrapper">

            {volist name='info.picArr' id='item'}
            <div class="swiper-slide"><img src="/{$item}" onerror="this.src='/static/mobile/img/empty_img.png'"></div>
            {/volist}

        </div>
        <div class="swiper-pagination head_page"></div>

    </div>
    <!--banner结束-->
    <script>
        var swiper = new Swiper('.head', {
            pagination: '.head_page',
            paginationClickable: true,
            spaceBetween: 30,
            centeredSlides: true,
            autoplay: 2500,
            autoplayDisableOnInteraction: false
        });
    </script>

    <!--限时抢购价格-->
    {if condition="$limit_status"}
    <input type="hidden" value="{:date('Y/m/d H:i:s',$end_time)}" id="end_time">
    <div style="overflow: hidden;width: 100%;">
        <div style="width: 64%;padding:5px 0 5px 3%;float: left;color:white;background: linear-gradient(to right,#E84109,#FEA700)">
            <div style="font-size: 12px;line-height: 18px;">￥<span style="font-size: 16px;">{$special_price}</span>
            </div>
            <div style="line-height: 18px;font-size: 12px;"><span
                    style="font-size: 10px;padding: 1px 5px 0;line-height:14px;border:1px solid white;border-radius: 6px;display: inline-block">限时抢购价</span><span
                    style="margin-left:5px;text-decoration: line-through;">￥{$info.price}</span></div>
        </div>
        <div style="width: 33%;padding:5px 0;float: left;background: #F6E5CF;color: #E73F09;font-size: 12px;line-height: 18px;text-align: center;"
             id="LeftTime">

            </span>

        </div>
    </div>
    {/if}
    <!--限时抢购价格-->


    <!--遮罩层开始-->
    <div id="shade" class="shade" style="display: none;width: 100%;" onclick="share()">
        <img src="__STATIC__/img_user/share_bg.png"
             style="position: absolute;left: 0;top: 0;z-index: 100000;width: 100%;">
    </div>
    <!--遮罩层结束-->
    <div class="center" style="padding-bottom: 0;">
        <h3><a href="#"><span style="color: white;display:inline-block;margin-right:3px;font-size:12px;line-height:16px;background: #E73F09;padding: 0 5px;border-radius: 4px;">{eq name="info.shop.type" value="个人"}自营{/eq}</span>{$info.title}</a>
        </h3>
        {if condition="$special_status eq ''&&$limit_status eq ''"}
        <p class="price">&yen;<span style="font-size: 18px;">{$info.price}<br></span></p>
        {/if}
        {if condition="$special_status"}
        <p class="price">&yen;<span style="font-size: 18px;">{$special_price}<br></span></p>
        <p class="price" style="color: #b3b3b3;font-size: 10px;text-decoration:line-through;">{$info.price}</p>
        {/if}
        <table>
            <tr><td style="text-align: left;">销量：{$info.sale_number}</td></tr>
        </table>
    </div>
    <div class="type">
        <ul>
            <li class="last">
                <a href="#">
                    <span style="color: #999;">送至：</span><span id="my_address">配送至{:reStrLen($address)}</span>
                    <img src="__STATIC__/img-new/new_more.png" class="next_address next" style="transform: scale(1);top:50%;margin-top: -10px;width: 20px;">
                </a>
            </li>
            <li class="last">
                <a href="#">
                    <span style="color: #999;">运费：</span><span id="freight">{$freight}</span>元
                </a>
            </li>
        </ul>
    </div>
    <div class="type">
        <ul>
            <li class="last" onclick="get_ticket({$info.member_id},{$info.id});">
                <a href="javascript:get_ticket({$info.member_id},{$info.id});">领取优惠券
                    <img src="__STATIC__/img_user/next1.png" class="next">
                </a>
            </li>
            <li onclick="selectAttr();">
                <a href="javascript:selectAttr();">
                    选择属性分类
                    <img src="__STATIC__/img_user/next1.png" class="next" onclick="selectAttr()"></a>
            </li>

        </ul>
    </div>
    <div class="board"></div>
    <div class="sppj" id="i_rew_con"
         onclick=window.location.href="{:url('mobile/user_category/goods_evaluate')}?goods_id={$info.id}">
        <p><a>商品评价({$info.evaluate})<img src="__STATIC__/img_user/next1.png" class="next"></a></p>
        {if condition="$info.evaluate_info"}
        <div class="review">
            <div class="title">
                <img src="{if condition=" !stristr($info.evaluate_info.member.avatar,'http')"}/{/if}{$info.evaluate_info.member.avatar}"
                onerror=this.src='/static/mobile/img/empty_img.png' >
                <p>{$info.evaluate_info.member.nickname}</p>
                <div class="star">
                    {for start='0' end="$info.evaluate_info.grade"}
                    <img src="__STATIC__/img_user/star.png">
                    {/for}
                </div>
            </div>
            <p>{$info.evaluate_info.content}</p>
            <div class="reply">
                <span>属性规格: {$info.evaluate_info.attr}</span>
            </div>
        </div>
        {/if}
        <ul>
            <li>
                <div>
                    <a href="{:url('mobile/user_category/goods_evaluate')}?goods_id={$info.id}&img=1"><span>有图评价 </span><img
                            src="__STATIC__/img_user/next3.png"></a></div>
            </li>
            <li>
                <div><a href="{:url('mobile/user_category/goods_evaluate')}?goods_id={$info.id}"><span>更多评价 </span><img
                        src="__STATIC__/img_user/next4.png"></a></div>
            </li>
        </ul>
    </div>
    <div class="store">
        <div class="info" style="overflow: hidden;">
            <img src="/{$info.shop.logo}" onerror=this.src="/static/mobile/img/empty_img.png"; style="float:left;">
            <div style="text-align: left;margin-left: 10px;float: left;">
                <h4><a>- {$info.shop.title} - </a></h4>
                <p><a>{$info.shop.description}</a></p>
            </div>
        </div>
        <ul>
            <li style="float: right;"><a href="javascript:jump_shop({$info.member_id});">
                <div style="display: inline-block;"><img src="__STATIC__/img/i_icon23.png"
                                                         style="width: 16px;height: 16px;margin-right: 5px;margin-top: 8px;float: left;">进入店铺
                </div>
            </a></li>
            <li style="float: left"><a href="javascript:shop_goods_cate({$info.member_id});">
                <div style="display: inline-block;"><img src="__STATIC__/img/i_icon22.png"
                                                         style="width: 16px;height: 16px;margin-right: 5px;margin-top: 8px;float: left;">查看分类
                </div>
            </a></li>
        </ul>
    </div>
    <!--套餐开始-->
    {if condition="$info.combo"}
    <div class="yhtc swiper-container">
        <p><a href="javascript:jump_combo({$info.combo.id});">优惠套餐<img src="__STATIC__/img_user/next1.png" class="next"></a>
        </p>
        <ul class="swiper-wrapper" style="overflow:visible">
            {volist name='info.combo.shopGoodsComboSelected' id='v'}
            <li class="pic swiper-slide">
                <a href="javascript:jump_goods_details({$v.goods_id});"><img src="/{$v.shopGoods.thumb_img}"
                                                                             style="height: 78px;width: 96px;"
                                                                             onerror=this.src="/static/mobile/img/empty_img.png">
                    <h4>{$v.shopGoods.title}</h4>
                    <p>&yen;{if condition="$v.shopSpecAttr.price"}{$v.shopSpecAttr.price}{else/}{$v.shopGoods.price}{/if}</p>
                </a>
            </li>
            <li class="and swiper-slide">
                <a><img src="__STATIC__/img_user/and.png"></a>
            </li>
            {/volist}
        </ul>
        <script>
            $(function () {
                var swiper = new Swiper('.yhtc', {
                    slidesPerView: 3.5,
                    spaceBetween: 15,
                    freeMode: true
                });
            })
        </script>
    </div>
    {/if}
    <!--套餐结束-->

    <!--新店铺推荐-->
    <div style="width: 100%;background: white;margin-bottom: 5px;">
        <span style="line-height: 40px;margin-left:3%;font-size: 12px;display: block;">店铺推荐</span>
        <ul class="list">
            {volist name="shop_goods" id='v'}
            <li style="margin-top: 0;margin-bottom: 1%;">
                <a href="{:url('mobile/user_category/goods_details')}?goods_id={$v.id}">
                    <div class="goods">
                        <img src="/{$v.thumb_img}" style="height: 78px;width: 96px;"
                             onerror=this.src='/static/mobile/img/empty_img.png'>
                    </div>
                    <h4>{$v.title}</h4>
                    <div style="overflow: hidden;width: 90%;margin: 0 auto;">
                        <div class="price" style="float: left;">&yen;{$v.price}</div>
                        <p>销量 {$v.sale_number}</p>
                    </div>
                </a>
            </li>
            {/volist}
        </ul>
    </div>
    <div class="tab" id="i_det_con">
        <div class="tablist">
            <ul>
                <li class="cur"><a><span>图文详情</span></a></li>
                <li><a><span>规格参数</span></a></li>
            </ul>
        </div>
        <div class="tabcon">
            <!--图文详情-->
            <div class="tw cur">
                {$info.content}
            </div>
            <!--规格参数-->
            <div>
                <table style="width: 100%;">
                    <tr>
                        <th>规格名称</th>
                        <th>规格参数</th>
                    </tr>
                    {if condition="$info.shopGoodsFlag"}
                    {volist name='info.shopGoodsFlag' id='item'}
                    <tr>
                        <td>{$item.flag_name}</td>
                        <td>{$item.flag_value}</td>
                    </tr>
                    {/volist}
                    {else}
                    <tr>
                        <td colspan="2" style="text-align: center;">未设置商品规格</td>
                    </tr>
                    {/if}

                </table>
            </div>
            <!--店铺推荐-->
        </div>
    </div>
    <img src="__STATIC__/img_user/top2.png" class="top">
    <!--底部开始-->
    <div class="footer">
        <ul class="list1">
            <li><a href="javascript:jump_shop({$info.member_id},{$info.id});"><img
                    src="__STATIC__/img/xq_icon1.png"><br><span>店铺</span></a></li>
            <li><a href="{$info.shop.mobile_url}"><img src="__STATIC__/img_user/sp-kefu.png"><br><span>客服</span></a>
            </li>
            <li><a href="javascript:collect({$info.id});"><img id="collect"
                                                               src="__STATIC__/img_user/goods_sc_{$collect_status}.png"><br><span>收藏</span></a>
            </li>
        </ul>
        {if condition="$limit_status"}
        <ul class="list2">
            <li hidden></li>
            <li style="width:100%;"><a href="#">立即购买</a></li>
        </ul>
        {else/}
        <ul class="list2">
            <li><a href="#">加入购物车</a></li>
            <li><a href="#">立即购买</a></li>
        </ul>
        {/if}
    </div>
    <!--底部结束-->
    <div class="board"></div>
    <!--选择属性开始-->
    <form action="{:url('mobile/user_category/order_yes')}" method="get" id="order">
        <div class="spsx">
            <div class="sp">
                <a href="javascript:void(0);"><img src="/{$info.picUrl}"
                                                   onerror=this.src="/static/mobile/img/empty_img.png"></a>
                <div>
                    <h4><a href="#">{$info.title} </a></h4>
                    <input type="hidden" name="goods_attr_id" id="goods_attr_id" value=""/>
                    <p>已选 <font id="text_selected"></font><span>&yen;<font id="selected_price">{if condition="$special_status||$limit_status"}{$special_price}{else}{$info.price}{/if}</font></span>
                    </p>
                    <input type="hidden" id="default_price"
                           value="{if condition='$special_status||$limit_status'}{$special_price}{else}{$info.price}{/if}"/>
                    <input type="hidden" name="goods_id" value="{$info.id}"/>
                    <input type="hidden" id="shop_id" value="{$info.member_id}"/>
                    <input type="hidden" id="special_status" {if condition="$special_status" }value="1" {else}value="0" {/if} />
                    <input type="hidden" id="address_id" value="{$address_id}">
                </div>
            </div>
            {if condition="$info.goods_attr"}
            {volist name='info.goods_attr' id='v'}
            <div class="size">
                <h4>{$key}</h4>
                <ul>
                    {volist name='v' id='vv' }
                    <li style="padding: 0 2%;" {eq name="i" value="1" } class="first cur selected_attr" {else/} class="first" {/eq}><a href="javascript:void(0);">{$vv}</a></li>
                    {/volist}
                </ul>
            </div>
            {/volist}
            {else/}
            {$empty}
            {/if}
            <div class="num">
                <div style="border-top:1px solid #F5F5F5;padding: 2% 0;">
                    <span>数量</span>
                    <ul>
                        <li onclick="jian()">-</li>
                        <li><input type="text" id="num" name="num" onkeyup="num_control(this,1)" value="1"
                                   style="width: 100%;outline: none;border: 0;text-align: center"/></li>
                        <li onclick="jia()">+</li>
                    </ul>
                </div>
            </div>
            <div class="footer1" >
                {if condition="$limit_status"}
                <!--限时抢购-->
                <ul class="list2" style="margin-left: 0px;">
                    <li hidden></li>
                    <li style="width: 100%;margin-left: 0px;"><a href="javascript:buy_now_limit();">立即抢购</a></li>
                </ul>
                {else/}
                <!--正常购买-->
                <ul class="list2">
                    <li><a href="javascript:in_cart({$info.id});">加入购物车</a></li>
                    <li><input type="button" id="submit" onclick="buy_now()" value="立即购买" style="line-height: 44px;"/></li>
                </ul>
                {/if}
            </div>
            <img src="__STATIC__/img_user/cancel.png" class="cancel">
        </div>
        <div class="address_det" style="min-height:300px;position: fixed;width: 94%;padding: 10px 3% 0 3%;background: white;bottom: 0!important;z-index: 102;display: none;">

            <img src="__STATIC__/img_user/cancel.png" class="cancel" style="position: absolute;right: 3%;top: -18px;">
            <div style="text-align: center;font-size: 18px;line-height: 40px;color: #333;">配送至</div>
            <ul>
                {volist name="my_address" id="item"}
                <li {eq name="address_id" value="item.id" }class="active" {/eq}><a href="javascript:chose_address({$item.id},{$info.member_id});">{$item.name} {$item.area_info}
                {$item.address}</a></li>
                {/volist}
            </ul>
        </div>


    </form>
    <!--选择属性结束-->

</div>
<div id="demo"></div>
{include file="public/src" /}
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>

<script>
    $(function () {
        //删除套餐多余的加号
        $('.and:last').remove();
    });


    //查看购物车
    function to_cart() {
        if ('{$Think.session.member_id}') {
            sessionStorage.setItem('cart_back_url', window.location.href);
            window.location.href = "{:url('mobile/user_cart/cart_index')}";
        } else {
            jump_login();
        }
    }

    function jump_shop(id) {
        var url = "{:url('mobile/user_category/shop_index')}?shop_id=" + id;
        sessionStorage.setItem('url_back', window.location.href);
        window.location.href = url;
    }
    //跳转到商品详情
    function jump_goods_details(id) {
        sessionStorage.setItem('goods_url_back', window.location.href);
        window.location.href = "{:url('mobile/user_category/goods_details')}?goods_id=" + id;
    }
    //获取优惠券
    function get_ticket(shop_id, goods_id) {
        if ("{$limit_status}") {
            window.location.href = "{:url('mobile/user_category/get_ticket')}?shop_id=" + shop_id + "&goods_id=" + goods_id + "&limit_status";
        } else {
            window.location.href = "{:url('mobile/user_category/get_ticket')}?shop_id=" + shop_id + "&goods_id=" + goods_id;
        }

    }
    // 跳转店铺
    function jump_shop(a, b) {
        sessionStorage.setItem('shop_back_url', window.location.href);
        window.location.href = "{:url('mobile/user_category/shop_index')}?shop_id=" + a + "&goods_id=" + b;
    }

    //跳转到套餐
    function jump_combo(id) {
        sessionStorage.setItem('combo_url', window.location.href);
        window.location.href = "{:url('mobile/user_category/combo_list')}?combo_id=" + id;
    }

    // 跳转店铺分类
    function shop_goods_cate(id) {
        sessionStorage.setItem('shop_cate_back', window.location.href);
        window.location.href = "{:url('mobile/user_category/shop_goods_cate')}?shop_id=" + id;
    }


    function num_control(o, n) {

        if (!/^\d+$/.test(o.value)) {
            o.value = o.value.replace(/[^\d]+/g, '');
        }
        if (o.value == '') {
            setTimeout(function () {
                if (o.value == '' || o.value === 0) {
                    o.value = n;
                }
            }, 1000);
        } else if (o.value >= 99) {
            o.value = 99
        } else if (o.value < 1) {
            o.value = 1;
            layer.open({content: '数量至少为 1', skin: 'msg', time: 2})
        }
    }
    //加入购物车
    function in_cart(id) {
        var num = $('#num').val(),
                attr = $('#text_selected').text(),
                price = $('#default_price').val(),
                shop_id = $('#shop_id').val(),
                special = $('#special_status').val(),
                attr_id = $('#goods_attr_id').val();
        $.ajax({
            url: "{:url('mobile/user_cart/default_cart')}",
            type: 'post',
            dateType: 'json',
            data: {
                'id': id,
                'attr': attr,
                'num': num,
                'price': price,
                'shop_id': shop_id,
                'attr_id': attr_id,
                'special': special
            },
            success: function (t) {
                if (t.code == 200) {
                    layer.open({content: t.message, skin: 'msg', time: 2});
                    $('.spsx').css('display', 'none');
                    $(".board").height("");
                } else if (t.code == 401) {   //未登录
                    jump_login(t.message);
                } else {
                    layer.open({content: t.message, skin: 'msg', time: 2});
//                    $('.spsx').css('display','none');
//                    $(".board").height("");
                }
            },
            error: function () {
                layer.open({content: '网络繁忙,请重试', skin: 'msg', time: 2});
            }
        })

    }
    //返回到来时的url
    function back_url() {
        var url = sessionStorage.getItem('come_order_yes');
        if (!url) {
            var url2 = sessionStorage.getItem('goods_url_back');
            if (url2) {
                window.location.href = sessionStorage.getItem('goods_url_back');
            } else {
                window.location.href = "{:url('mobile/user_port/index')}";
            }

        } else {
            sessionStorage.removeItem('come_order_yes');
            window.location.href = url;
        }
    }
    //未登录跳转到登录
    function jump_login() {

        window.location.href = "{:url('mobile/user_port/login')}";
    }
    //加入购物车转确认订单(立即购买)
    function buy_now() {
        var special = $('#special_status').val();
        var address_id = $('#address_id').val();

        $('#order').ajaxSubmit({
            url: "{:url('mobile/user_cart/confirm_order')}",
            type: 'post',
            dataType: 'json',
            data: {'price': $('#selected_price').text(), 'attr': $('#text_selected').text(), 'special': special},
            success: function (t) {
                if (t.code == 200) {
                    sessionStorage.setItem('goods_order_yes_url', window.location.href);   //确认订单返回的路径
                    window.location.href = "{:url('mobile/user_category/order_yes')}?act=temporary&cart_id=" + t.message + "&address_id=" + address_id;
                } else if (t.code == 401) {
                    jump_login(t.message);
                } else {
                    layer.open({content: t.message, skin: 'msg', time: 2});
                }
            },
            error: function () {
                layer.open({content: '网络繁忙,请重试', skin: 'msg', time: 2});
            }
        })
    }
    //确认订单(立即抢购)
    function buy_now_limit() {
        var goods_id = $("[name='goods_id']").val();
        var num = $('#num').val();
        var attr = $('#text_selected').text();
        $.post("{:url('mobile/user_cart/buy_limit')}", {
            'panic': 1,
            'goods_id': goods_id,
            'num': num,
            'attr': attr
        }, function (data) {
            if (data.code == 200) {   //符合条件
                sessionStorage.setItem('goods_order_yes_url', window.location.href);
                var text = goods_id + '|' + data.attr_id + '|' + num;
                window.location.href = "{:url('mobile/user_category/order_yes')}?limited=" + text;
            } else if (data.code == 401) {
                jump_login(data.message);
            } else {
                layer.open({content: data.message, skin: 'msg', time: 2});
            }
        })
    }

    function attr_id(id) {
        $("[name='attr_id']").val(id);
    }
    //收藏商品
    function collect(id) {
        if (!'{$Think.session.member_id}') {
            jump_login('您还未登录,请登录');
            return false
        }
        $.ajax({
            url: "member_collect",
            type: 'post',
            dataType: 'json',
            data: {'type': 1, 'id': id},
            success: function (t) {
                if (t.code == 200) {
                    $('#collect').prop('src', '__STATIC__/img_user/goods_sc_1.png');
                    layer.open({content: t.message, skin: 'msg', time: 2});
                } else if (t.code == 100) {
                    $('#collect').prop('src', '__STATIC__/img_user/goods_sc_0.png');
                    layer.open({content: t.message, skin: 'msg', time: 2});
                } else {
                    layer.open({content: t.message, skin: 'msg', time: 2});
                }
            },
            error: function () {
                layer.open({content: '网络繁忙,请重试', skin: 'msg', time: 2});
            }
        })
    }
    //改变价格(已改掉)
    function change_price() {
        var num = $('#num').val(),
                default_price = $('#default_price').val();
        $('#selected_price').text(parseFloat(num * default_price).toFixed(2));
    }
    function jian() {
        var num = $('#num');
        if (num.val() == 1) {
            layer.open({content: '不能再减了', skin: 'msg', time: 2});
            return false;
        }
        num.val(num.val() - 1);
    }
    function jia() {
        var num = $('#num');
        num.val(parseInt(num.val()) + 1);
    }

    function chose_address(id,shop) {
        $.ajax({
            url: "choseDetailAddress",
            type: 'get',
            dataType: 'json',
            data: {'id': id,'shop':shop},
            success:function (t) {
                if (t.code==200) {
                    $("#my_address").text(t.address);
                    $("#address_id").val(t.address_id);
                    $("#freight").text(t.freight);
                    $('.address_det').hide();
                    $('.board').height(0);
                }
            }
        });
    }
    {present name="$jsSign.appId"}
    wx.config({
        debug: false,
        appId: '{$jsSign.appId}',
        timestamp: '{$jsSign.timestamp}',
        nonceStr: '{$jsSign.nonceStr}',
        signature: "{$jsSign.signature}",
        jsApiList: [
            'onMenuShareTimeline',  //分享到朋友圈
            'onMenuShareAppMessage',    //分享给微信朋友
            'onMenuShareQQ',        //分享给qq
            'onMenuShareQZone',     //分享到qq空间
        ]
    });
    {/present}
    //分享


    wx.ready(function () {
        //		分享到朋友圈
        wx.onMenuShareTimeline({
            title: '龙采Ishop', // 分享标题
            link: window.location.href, // 分享链接
            imgUrl: 'http://app50.app.longcai.net/static/mobile/img_user/qrcode_logo.jpg', // 分享图标
            success: function () {
                // 用户确认分享后执行的回调函数
            },
            cancel: function () {
                // 用户取消分享后执行的回调函数
            }
        });
        //		分享给朋友
        wx.onMenuShareAppMessage({
            title: '龙采Ishop', // 分享标题
            desc: '龙采Ishop', // 分享描述
            link: window.location.href, // 分享链接
            imgUrl: 'http://app50.app.longcai.net/static/mobile/img_user/qrcode_logo.jpg', // 分享图标
            success: function () {
                // 用户确认分享后执行的回调函数
            },
            cancel: function () {
                // 用户取消分享后执行的回调函数
            }
        });
        wx.onMenuShareQQ({
            title: '龙采Ishop', // 分享标题
            desc: '龙采Ishop', // 分享描述
            link: window.location.href, // 分享链接
            imgUrl: 'http://app50.app.longcai.net/static/mobile/img_user/qrcode_logo.jpg', // 分享图标
            success: function () {
                // 用户确认分享后执行的回调函数
            },
            cancel: function () {
                // 用户取消分享后执行的回调函数
            }
        });
        wx.onMenuShareQZone({
            title: '龙采Ishop', // 分享标题
            desc: '龙采Ishop', // 分享描述
            link: window.location.href, // 分享链接
            imgUrl: 'http://app50.app.longcai.net/static/mobile/img_user/qrcode_logo.jpg', // 分享图标
            success: function () {
                // 用户确认分享后执行的回调函数
            },
            cancel: function () {
                // 用户取消分享后执行的回调函数
            }
        });
    });
    //分享弹出层
    function share() {
        var ua = window.navigator.userAgent.toLowerCase();
        if (ua.match(/MicroMessenger/i) == 'micromessenger') {
            showdiv();
        } else {
            layer.open({content: '请到微信浏览器内访问本页面', skin: 'msg', time: 4})
        }
    }
    //遮罩层
    function showdiv() {
        var target = document.getElementById('shade');
        if (target.style.display == "none") {
            target.style.display = "block";
            $('body').css('overflow-y', 'hidden');
            document.documentElement.ontouchmove = function () {
                return false;
            };
        } else {
            document.documentElement.ontouchmove = function () {
                return true;
            };
            target.style.display = "none";
            $('body').css('overflow-y', '');
        }
    }
</script>

{if condition="$special_status||$limit_status"}
<script>
    //倒计时效果js代码
    function checktime(i) {
        if (i < 10) {
            i = "0" + i;

        }
        else {
            i = i;
        }
        return i;
    }
    function freshTime() {
        var endtime = new Date($('#end_time').val());
        var nowtime = new Date();
        var lefttime = parseInt(endtime.getTime() - nowtime.getTime());//这是毫秒，如果再/1000就是秒
        // 获取剩下的日、小时、分钟、秒钟
        // 一天有多少毫秒，一小时有多少毫秒，一分钟有多少毫秒，一秒钟有多少毫秒
        var dm = 24 * 60 * 60 * 1000;
        var d = parseInt(lefttime / dm);
        var hm = 60 * 60 * 1000;
        var h = parseInt((lefttime / hm) % 24);
        var mm = 60 * 1000;
        var m = parseInt((lefttime / mm) % 60);
        var s = parseInt((lefttime / 1000) % 60);
        m = checktime(m);
        s = checktime(s);
        document.getElementById('LeftTime').innerHTML = "距结束还剩：<br><span style='color: white;font-size: 12px;line-height: 18px;width: 18px;text-align: center;background: #E73F09;border-radius: 4px;display: inline-block;'>" + h + "</span>&nbsp;:&nbsp;<span style='color: white;font-size: 12px;line-height: 18px;width: 18px;text-align: center;background: #E73F09;border-radius: 4px;display: inline-block;'>" +
                m + "</span>&nbsp;:&nbsp;<span style='color: white;font-size: 12px;line-height: 18px;width: 18px;text-align: center;background: #E73F09;border-radius: 4px;display: inline-block;'>" + s + "</span>";
        if (lefttime < 0) {
            document.getElementById('LeftTime').innerHTML = "团购活动已经结束！";
        }
    }
    freshTime();
    var sh;
    sh = setInterval('freshTime()', 1000);

</script>
{/if}
</body>
</html>